import api from "./request/request.js"
export default {
	judgeToken() {
		let pages = getCurrentPages(); // 获取栈实例
		const perpage = pages[pages.length - 1]
		let url = '/' + perpage.route + '?'

		for (let i in perpage.options) {
			console.log(i, perpage.options[i])
			url = url + i + '=' + perpage.options[i] + '&'
		}
		uni.setStorageSync('pageUrl', url)
		uni.reLaunch({
			url:'/Login/loginPage'
		})
	},
	back() {
		let pages = getCurrentPages(); // 获取栈实例
		let prevPage = pages[pages.length - 2]; // 获取上个页面的数据，包含页面路由
		if (!prevPage) {
			uni.reLaunch({
				url: '/Home/index'
			});
		} else {
			uni.navigateBack();
		}
	},
	navigateTo(obj) {
		let pages = getCurrentPages();
		if (pages.length > 8) {
			uni.reLaunch({
				url: obj.url
			})
			return
		}
		uni.navigateTo({
			url: obj.url
		})
	}
};